package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.ColorMatrixFilter;

	public class Button extends ImageSprite
	{
		protected var renderSprite:Render;
		protected var menu:Menu;
		private var clickable:Boolean=true;
		
		public function Button(m:Sprite)
		{
			menu=m as Menu;
			//cacheAsBitmap = true;
			this.addEventListener(MouseEvent.CLICK,send);
		}
		public function giveRenderSprite(r:Sprite):void{
			renderSprite = r as Render;
		}
		protected function send(e:Event):void{
			renderSprite.buildingChosen(filename);
		}
		public function getType():String{
			return filename;
		}
		public function setClickable(b:Boolean):void{
			clickable = b;
			
			if(!b){
				//dim the button
				this.filters = [Formatting.greyscaleFilter];
				mouseEnabled = false;
				mouseChildren = false;
			} else {
				trace("building unlocked");
				//undim the button
				this.filters = [];
				mouseEnabled = true;
				mouseChildren = true;
			}
			
			
		}
	}
}